package mobi.hami.huapin.service.impl;

import mobi.hami.huapin.dao.PrintLogMapper;
import mobi.hami.huapin.model.PrintLog;
import mobi.hami.huapin.service.PrintLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.Map;

/**
 * 类说明
 *
 * @author 阿飞 jijunjian@hami.mobi
 * @date 10/9/2018 9:40 PM
 */
@Service
public class PrintLogServiceImpl implements PrintLogService {

    @Autowired
    PrintLogMapper logMapper;

    /**
     * 保存打印记录
     *
     * @param reqmap
     * @return
     */
    @Override
    public int save(Map<String, String> reqmap) {

        PrintLog log = new PrintLog();
        log.setAdmin(reqmap.get("admin"));
        log.setHp_id(Long.parseLong(reqmap.get("hp_id")));
        log.setGmt_create(new Date());

        logMapper.insertSelective(log);

        return 1;
    }

    /**
     * 查询打印次数
     *
     * @param huapin_id
     * @return
     */
    @Override
    public int queryPrintCount(long huapin_id) {
        return logMapper.queryPrintCount(huapin_id);
    }
}
